package org.metasketch.simulator.configuration.loaders;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

import org.metasketch.simulator.transformation.PetriNetSimulationPackage;

public class SimulationConfigLoader {

	public static SimulationConfig load(File file) throws Throwable {

		FileReader fr = new FileReader(file);
		BufferedReader br = new BufferedReader(fr);
		String time = br.readLine();

		Long timeInSeconds = null;

		if (time.endsWith("h")) {
			time = time.substring(0, time.length() - 1);
			timeInSeconds = Long.valueOf(time);
			timeInSeconds *= 3600;
		} else
			timeInSeconds = Long.valueOf(time);

		Long seed = null;

		String seedString = br.readLine();
		if (!seedString.equals("false"))
			seed = Long.valueOf(seedString);

		fr.close();

		SimulationConfig cfg = new SimulationConfig();

		cfg.setTime(timeInSeconds);
		cfg.setSeed(seed);

		return cfg;

	}
}
